package com.qf.function;

import com.qf.function.pojo.User;
import com.sun.org.apache.bcel.internal.generic.NEW;

import java.util.function.BiFunction;
import java.util.function.BinaryOperator;

/*
 *@Description:
 *@author:刘哥
 *@Date:86180 2022/9/2 14:54
 */
public class BiFunctionTest {
    public static void main(String[] args) {
//        BiFunction<> biFunction= new BiFunction() {
//            @Override
//            public Object apply(Object o, Object o2) {
//                return null;
//            }
//        };
//        、前两个个参数是参数,第三个是返回值
        BiFunction<String, Integer, User> biFunction = (name, age) -> {
            User user = new User();
            user.setName(name);
            user.setAge(age);
            return user;
        };
        User user = biFunction.apply("张三", 18);
        System.out.println("user = " + user);

//        BinaryOperator<String> stringBinaryOperator = new BinaryOperator<String>(){
//
//            @Override
//            public String apply(String s, String s2) {
//                return null;
//            }
//        };
        BinaryOperator<String> binaryOperator = (name, address) -> {
            User user1 = new User();
            user1.setName(name);
            user1.setAddresss(address);
            return user1.toString();
        };
        String apply = binaryOperator.apply("王五", "北京");
        System.out.println("apply = " + apply);
    }
}
